package com.example.starapp.home;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.example.starapp.R;

import java.util.ArrayList;
import java.util.List;

public class GuideActivity extends AppCompatActivity {
    ViewPager guideVp;
    int []imgIds = {R.mipmap.loading1,R.mipmap.loading2,R.mipmap.loading3};
    List<ImageView> imgList;  //ViewPager的存放view的集合
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
        guideVp = findViewById(R.id.guide_vp);
        imgList = new ArrayList<>();
        for (int i = 0; i < imgIds.length; i++) {
            ImageView iv = new ImageView(this);
            iv.setImageResource(imgIds[i]);
            iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
            iv.setLayoutParams(lp);
            imgList.add(iv);
        }
//        创建适配器
        GuidePagerAdapter adapter = new GuidePagerAdapter(this, imgList);
//        设置适配器
        guideVp.setAdapter(adapter);

    }
}